package cn.bdqn.service.sys.impl;

import cn.bdqn.dao.sys.SysJournalDao;
import cn.bdqn.entity.SysLog;
import cn.bdqn.service.sys.SysJournalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

/**
 * @ProjectName: ycbdqn
 * @Package: cn.bdqn.service.sys.impl
 * @Author: huat
 * @Date: 2020/3/9 18:36
 * @Version: 1.0
 */
@Service
public class SysJournalServiceImpl implements SysJournalService {
    @Autowired
    SysJournalDao sysJournalDao;
    /**
     * 查看日志
     * @param page 起始位置
     * @param limit 页面大小
     * @param username 操作用户名
     * @param operation 操作
     * @return
     */
    @Override
    public Map<String, Object> getJournal(Integer page, Integer limit, String username, String operation) {
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("count",sysJournalDao.countJournal(username, operation));
        map.put("data",sysJournalDao.getAllSysLog((page-1)*limit, limit, username, operation));
        map.put("code",0);
        return map;
    }
    /**
     * 保存日志
     * @param sysLog
     * @return
     */
    @Override
    @Transactional
    public int saveSysLog(SysLog sysLog) {

        return sysJournalDao.addSysLog(sysLog);
    }
}
